<!DOCTYPE html>
<html>
    <head>
        <title>发布订阅</title>
        <script src="../../src/pub-sub/pub-sub.js"></script>
    </head>
    <body>
        <script>
            // 订阅一个频道
            let pid1 = PubSub.subscribe('pay', data => {
                console.log("商家收到了支付信息：" + data)
            })

            let pid2 = PubSub.subscribe('pay', data => {
                console.log("骑手收到了支付信息：" + data)
            })

            PubSub.subscribe("cancel", data => {
                console.log("商家收到了取消信息：" + data)
            })

            // console.log(pid1, pid2)

            

            PubSub.publish('pay', {
                title: '麻辣烫',
                price: 20,
                pos: '北京市海淀区'
            })
        </script>
    </body>
</html>